<template>
    <div class="layui-form-item">
        <div class="layui-row">
            <div class="layui-col-xs7">
                <label class="layadmin-user-login-icon layui-icon <%= icon %>"></label>
                <input type="<%= inputType %>" id="<%= 'input-' + inputType +'-'+ name %>" name="<%= name %>"
                <% if ( verify ) { %> lay-verify="<%= verify %>" <% } %> placeholder="<%= placeholder %>"
                    class="layui-input">
            </div>
            <div class="layui-col-xs5">
                <div style="margin-left: 10px;">
                    <img src="<%= codeUrl %>" class="layadmin-user-login-codeimg" id="img-code-<%= name %>">
                </div>
            </div>
        </div>
    </div>
</template>
<script name="compile">
    function templateCompile(data) {
        var defaultData = {
            type: "module",
            placeholder: "",
            inputType: "text",
            verify: "required",
        };
        var callback = {
            success: true,
            result: Object.assign(defaultData, data)
        };
        if (!data.placeholder) {
            return {
                success: false,
                result: "请输入表单提示，参数名：placeholder"
            };
        }
        if (!data.name) {
            return {
                success: false,
                result: "请输入参数名称，参数名：name"
            };
        }
        if (!data.icon) {
            return {
                success: false,
                result: "请选择表单图标，参数名：icon"
            };
        }
        if (!data.codeUrl) {
            return {
                success: false,
                result: "请输入验证码图片地址，参数名：codeUrl"
            };
        }
        return callback;
    }
</script>
<script name="templateScript">
    $("#img-code-<%= name %>").on("click", function () {
        $(this).attr("src","<%= codeUrl %>?t="+new Date().getTime());
    });
    //&&insertStart:(scriptchildren1)&&
    $("#img-code-<%= name %>").attr("src","<%= codeUrl %>?t="+new Date().getTime());
    //&&insertEnd&&
</script>